#include <iostream>
#include <vector>

using namespace std;

// https://leetcode.cn/problems/lexicographical-numbers/?envType=daily-question&envId=2025-06-08
// 386. 字典序排数

class Solution
{
public:
    vector<int> lexicalOrder(int n)
    {
        vector<int> ans;
        int number = 1;
        for (int i = 0; i < n; i++)
        {
            ans.push_back(number);
            if (number * 10 <= n)
            {
                number *= 10;
            }
            else
            {
                while ((number + 1) %10 == 0 || number + 1 > n )
                {
                    number /= 10;
                }
                ++number;
            }
        }
        return ans;
    }
};

int main()
{
    return 0;
}